﻿#include <stdio.h>
#include <string.h>
int a[100][10][10];
int main()
{
    int n, i, j, k;
    scanf("%d", &n);
    int m[110];
    int countmax = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%d", &m[i]);
        if (m[i] > countmax)
        {
            countmax = m[i];
        }
    }
    int lasti = -1;
    int bianhao = 0;
    for (j = 0; j < countmax; j++)
    {
        for (k = 0; k < 10; k++)
        {
            for (i = 0; i < n; i++)
            {
                if (j < m[i])

                              
                                
                {
                    if (lasti == i)
                    {               
                                       
                                    
                        bianhao += 2;
                    }
                    else
                    {
                        bianhao++;
                    }
                    a[i][j][k] = bianhao;
                    lasti = i;
                }
            }
        }
    }
    for (i = 0; i < n; i++)
    {
        printf("#%d\n", i + 1);
        for (j = 0; j < m[i]; j++)
        {
            for (k = 0; k < 9; k++)
            {
                printf("%d ", a[i][j][k]);
            }
            printf("%d\n", a[i][j][k]);
        }
    }
    return 0;
}
